<template>
  <div class="task-options-menu" @click.stop>
    <div class="menu-item" @click="$emit('add-to-star'); $emit('close')">
      <el-icon><Star /></el-icon>
      <span>添加到"加星"</span>
    </div>
    <div class="menu-item" @click="$emit('add-deadline'); $emit('close')">
      <el-icon><Clock /></el-icon>
      <span>添加截止时间</span>
    </div>
    <div class="menu-item" @click="$emit('add-subtask'); $emit('close')">
      <el-icon><List /></el-icon>
      <span>添加子任务</span>
    </div>
    <div class="menu-divider"></div>
    <div class="menu-item danger" @click="$emit('delete'); $emit('close')">
      <el-icon><Delete /></el-icon>
      <span>删除</span>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { Star, Clock, List, Delete } from '@element-plus/icons-vue'

defineEmits<{
  (e: 'add-to-star'): void
  (e: 'add-deadline'): void
  (e: 'add-subtask'): void
  (e: 'delete'): void
  (e: 'close'): void
}>()
</script>

<style scoped>
.task-options-menu {
  position: absolute;
  z-index: 9999;
  width: 180px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  margin: 0;
  list-style: none;
  border: 1px solid #eee;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: background-color 0.2s;
}

.menu-item:hover {
  background-color: #f5f7fa;
}

.menu-item .el-icon {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.menu-item.danger {
  color: #ff4d4f;
}

.menu-divider {
  height: 1px;
  background-color: #eee;
  margin: 4px 0;
}
</style>